<<<<<<< HEAD
import React, { useEffect } from 'react'
import styles from './css/look.less'
import { useDispatch, useSelector, useHistory, useLocation } from 'umi'
import { Select, Form, Input, Button, message } from 'antd';
import { IQuestionType, ISubject, IExamType, IQuestionForm } from '@/utils/interface'
const watchQuestions: React.FC = () => {

  const dispatch = useDispatch()
  const { newTypes } = useSelector(module => (module as { addQuestions: { newTypes: [] } }).addQuestions)
  const { examTypes } = useSelector(module => (module as { addQuestions: { examTypes: [] } }).addQuestions)
  const { subjects } = useSelector(module => (module as { addQuestions: { subjects: any[] } }).addQuestions)
  const { questionTypes } = useSelector(module => (module as { addQuestions: { questionTypes: any[] } }).addQuestions)
  const editorLayout = {
    wrapperCol: { span: 20 }
  }
  const { Option } = Select
  //派发dispatch
  useEffect(() => {
    dispatch({
      type: "addQuestions/newType",
    })
    dispatch({
      type: 'addQuestions/getExamType'
    })
    dispatch({
      type: 'addQuestions/getExamSubject'
    })
    dispatch({
      type: 'addQuestions/getQuestionType',
    })
  }, [])
  return (
    <div className={styles.wrap}>
      <h1>查看试题</h1>
      <div className={styles.content}>
        <div className={styles.cona}>
          <p>课程类型:</p>
          <div className={styles.conaa}>
            <p >All</p>
            {
              subjects?.map((item) => {
                return <span key={item.subject_id}>{item.subject_text}</span>
              })
            }
          </div>

        </div>
        <div className={styles.bodys}>
          <Form>
            <div>
              <label htmlFor="">考试类型：</label>
              <Form.Item
                name="exam_id"
                // {...editorLayout}
              >
                <Select style={{ width: 250 }}>{
                  (examTypes as IExamType[]).map(item => {
                    return <Option key={item.exam_id} value={item.exam_id}>{item.exam_name}</Option>
                  })
                }</Select>
              </Form.Item>
            </div>
            <div>
              <label htmlFor="">题目类型：</label>
              <Form.Item
                name="questions_type_id"
                {...editorLayout}
              >
                <Select style={{ width: 250 }}>{
                  (questionTypes as IQuestionType[]).map(item => {
                    return <Option key={item.questions_type_id} value={item.questions_type_id}>{item.questions_type_text}</Option>
                  })
                }</Select>
              </Form.Item>
            </div>
            <Button type="primary" htmlType="submit" className={styles.btn}>
              查询
                    </Button>
          </Form>
        </div>
      </div>
      <div className={styles.bottom}>
        {
          newTypes && newTypes.map((item: any) => {
            return <div>
                   <p> {item.title}</p>
                        <div className={styles.center}>
=======
import { IExamQuestions, IExamType, IQuestionType, ISubject } from "@/utils/interface"
import React, { useEffect, useRef } from "react"
import { useSelector, useDispatch } from "umi"
import styles from './watchQuestions.less'
import { Select, Form, Input, Button, message } from 'antd';
const watchQuestions: React.FC = () => {
    const selectAll = useRef(null)
    const dispatch = useDispatch()
    const { Option } = Select
    const editorLayout = {
        wrapperCol: { span: 20 }
    }
    useEffect(() => {
        dispatch({
            type: 'question/getQuestionType'
        })
        dispatch({
            type: 'question/getExamSubject'
        })
        dispatch({
            type: 'question/getExamType'
        })
        dispatch({
            type:'question/getExamQuestions'
        })
    }, [])
    const { subjects } = useSelector(module => (module as { question: { subjects: ISubject[] } }).question)
    const { examTypes } = useSelector(module => (module as { question: { examTypes: IExamType[] } }).question)
    const { questionTypes } = useSelector(module => (module as { question: { questionTypes: IQuestionType[] } }).question)
    const {examQuestions} = useSelector(module=>(module as {question:{examQuestions:IExamQuestions[]}}).question)
    function selectClass(e: React.MouseEvent<HTMLDivElement>) {
        if ((e.target as HTMLDivElement).tagName === 'SPAN') {
            if ((e.target as HTMLDivElement).classList.contains('active')) {
                (e.target as HTMLDivElement).classList.remove('active')
            } else {
                (e.target as HTMLDivElement).classList.add('active')
            }
        }
        if ((e.target as HTMLDivElement).tagName === 'P') {
            let arr = [...(selectAll.current as unknown as Element).querySelectorAll('span')]
            console.log(arr)
            if ((e.target as HTMLDivElement).classList.contains('active')) {
                (e.target as HTMLDivElement).classList.remove('active')
                arr.forEach(item => item.classList.remove('active'))
            } else {
                (e.target as HTMLDivElement).classList.add('active')
                arr.forEach((item) => {
                    item.classList.add('active')
                })
            }
        }
    }
    useEffect(() => {
        console.log('aaaaaaaaaaaaaaaaaaa', subjects)
    }, [])
    return <div className={styles.wrap}>
        <h1>查看试题</h1>
        <div className={styles.cotent}>
            <div className={styles.class} >
                <p>课程类型:</p>
                <div onClick={selectClass} ref={selectAll}>
                    <p >All</p>
                    {
                        subjects?.map((item) => {
                            return <span key={item.subject_id}>{item.subject_text}</span>
                        })
                    }
                </div>
            </div>
            <div className={styles.bodys}>
                <Form>
                    <div>
                        <label htmlFor="">考试类型：</label>
                        <Form.Item
                            name="exam_id"
                            {...editorLayout}
                        >
                            <Select style={{width:250}}>{
                                (examTypes as IExamType[]).map(item => {
                                    return <Option key={item.exam_id} value={item.exam_id}>{item.exam_name}</Option>
                                })
                            }</Select>
                        </Form.Item>
                    </div>
                    <div>
                        <label htmlFor="">题目类型：</label>
                        <Form.Item
                            name="questions_type_id"
                            {...editorLayout}
                        >
                            <Select style={{width:250}}>{
                                (questionTypes as IQuestionType[]).map(item => {
                                    return <Option key={item.questions_type_id} value={item.questions_type_id}>{item.questions_type_text}</Option>
                                })
                            }</Select>
                        </Form.Item>
                    </div>
                    <Button type="primary" htmlType="submit" className={styles.btn}>
                        查询
                    </Button>
                </Form>
            </div>
        </div>
        <div className={styles.footer}>
            {
                examQuestions.map((item,index)=>{
                    return <div key={index}>
                        <p> {item.title}</p>
                        <div>
>>>>>>> de54b307166b277708c9f443ac2c9a94aa3cb036
                            <span>{item.questions_type_text}</span>
                            <span>{item.subject_text}</span>
                            <span>{item.exam_name}</span>
                        </div>
<<<<<<< HEAD
                        <div className={styles.c2}>
                            {item.user_name} 发布
                        </div>
            </div>
          })
        }
      </div>

    </div>
  );
}
=======
                        <div>
                            {item.user_name} 发布
                        </div>
                    </div>
                })
            }
        </div>
    </div>
}

>>>>>>> de54b307166b277708c9f443ac2c9a94aa3cb036
export default watchQuestions